package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.po.DeliveryAddress;
import com.neusoft.elmboot.service.DeliveryAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/DeliveryAddress")
public class DeliveryAddressController {
	@Autowired
	private DeliveryAddressService deliveryAddressService;

	@GetMapping("/DeliveryAddressList")
	public List<DeliveryAddress> listDeliveryAddressByUserId(DeliveryAddress deliveryAddress) throws Exception {
		return deliveryAddressService.listDeliveryAddressByUserId(deliveryAddress.getUserId());
	}

	@GetMapping("/DaId")
	public DeliveryAddress getDeliveryAddressById(DeliveryAddress deliveryAddress) throws Exception {
		return deliveryAddressService.getDeliveryAddressById(deliveryAddress.getDaId());
	}

	@PostMapping("/DaId")
	public int saveDeliveryAddress(DeliveryAddress deliveryAddress) throws Exception {
		return deliveryAddressService.saveDeliveryAddress(deliveryAddress);
	}

	@PutMapping("/DaId")
	public int updateDeliveryAddress(DeliveryAddress deliveryAddress) throws Exception {
		return deliveryAddressService.updateDeliveryAddress(deliveryAddress);
	}

	@DeleteMapping("/DaId")
	public int removeDeliveryAddress(DeliveryAddress deliveryAddress) throws Exception {
		return deliveryAddressService.removeDeliveryAddress(deliveryAddress.getDaId());
	}
}